<html>
<head>
	<title>Thanks! </title>
</head>
<body>
<center>
<br>
<?php 
//Rquire MySqlAdapter.
require_once(dirname(__FILE__).'/../db/MySqlAdapter.php');

//echo "<br>Step 1: open a connection to the DB<br>";
$conn = MySqlAdapter::connect1();

if (isset($_REQUEST['takeorreturn']) && isset($_REQUEST['orderid']) )
{
	if (($_REQUEST['takeorreturn']) && ($_REQUEST['orderid']) )
	{
		if ($conn):
			$result = MySqlAdapter::connect2();
		else:
			die ("Could not connect to db " . mysql_error());
		endif;

		//echo "<br>Step 2: update reservation of equipments table<br>";
		$query = "UPDATE `ohel_shelomo_2012`.`reservation` SET `".$_REQUEST['takeorreturn']."` = '1' WHERE `reservation`.`id` =".$_REQUEST['orderid'].";";
		mysql_query($query) or die ("Invalid UPDATE " . mysql_error());
		
		if($_REQUEST['takeorreturn']=="wastaken"){
			print("Thanks !<br>\n\t Item ID: ".$_REQUEST['orderid']." was taken successfully");
		} else if($_REQUEST['takeorreturn']=="wasreturned"){
				print("Thanks !<br>\n\t Item ID: ".$_REQUEST['orderid']." was returned successfully");
			}else
					print("Sorry, could not prosses your request.");
	}
	else
		{ echo "Please fill all the fileds.";}
}
	else
		{ echo "Please fill all the fileds. Or enter this page in the acceptable way";}
?>
<br/><br/>
<A HREF="javascript:history.back()">Back</A>
<?php
mysql_close($conn);
?>
</center>
</body>
</html>